home *** CD-ROM | disk | FTP | other *** search
/ Languguage OS 2 / Languguage OS II Version 10-94 (Knowledge Media)(1994).ISO / gnu / glibc108.zip / glibc108 / resource / sys / resource.h next >
C/C++ Source or Header  |  1994-05-18  |  6KB  |  155 lines

  1. /* Copyright (C) 1992, 1994 Free Software Foundation, Inc.
  2. This file is part of the GNU C Library.
  3.  
  4. The GNU C Library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public License as
  6. published by the Free Software Foundation; either version 2 of the
  7. License, or (at your option) any later version.
  8.  
  9. The GNU C Library is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
  12. Library General Public License for more details.
  13.  
  14. You should have received a copy of the GNU Library General Public
  15. License along with the GNU C Library; see the file COPYING.LIB.  If
  16. not, write to the Free Software Foundation, Inc., 675 Mass Ave,
  17. Cambridge, MA 02139, USA.  */
  18.  
  19. #ifndef    _SYS_RESOURCE_H
  20.  
  21. #define    _SYS_RESOURCE_H    1
  22. #include <features.h>
  23.  
  24. __BEGIN_DECLS
  25.  
  26. /* Get the system-dependent definitions of RLIM_*.  */
  27. #include <resourcebits.h>
  28.  
  29. struct rlimit
  30.   {
  31.     /* The current (soft) limit.  */
  32.     int rlim_cur;
  33.     /* The hard limit.  */
  34.     int rlim_max;
  35.   };
  36.  
  37. /* Value used to indicate that there is no limit.  */
  38. #define RLIM_INFINITY 0x7fffffff
  39.  
  40. /* Put the soft and hard limits for RESOURCE in *RLIMITS.
  41.    Returns 0 if successful, -1 if not (and sets errno).  */
  42. int getrlimit __P ((enum __rlimit_resource __resource,
  43.             struct rlimit * __rlimits));
  44.  
  45. /* Set the soft and hard limits for RESOURCE to *RLIMITS.
  46.    Only the super-user can increase hard limits.
  47.    Return 0 if successful, -1 if not (and sets errno).  */
  48. int setrlimit __P ((enum __rlimit_resource __resource,
  49.             struct rlimit * __rlimits));
  50.  
  51.  
  52. /* Whose usage statistics do you want?  */
  53. enum __rusage_who
  54. /* The macro definitions are necessary because some programs want
  55.    to test for operating system features with #ifdef RUSAGE_SELF.
  56.    In ANSI C the reflexive definition is a no-op.  */
  57.   {
  58.     /* The calling process.  */
  59.     RUSAGE_SELF = 0,
  60. #define    RUSAGE_SELF    RUSAGE_SELF
  61.     /* All of its terminated child processes.  */
  62.     RUSAGE_CHILDREN = -1,
  63. #define    RUSAGE_CHILDREN    RUSAGE_CHILDREN
  64.   };
  65.  
  66. #include <sys/time.h>        /* For `struct timeval'.  */
  67.  
  68. /* Structure which says how much of each resource has been used.  */
  69. struct rusage
  70.   {
  71.     /* Total amount of user time used.  */
  72.     struct timeval ru_utime;
  73.     /* Total amount of system time used.  */
  74.     struct timeval ru_stime;
  75.     /* Maximum resident set size (in kilobytes).  */
  76.     long ru_maxrss;
  77.     /* Amount of sharing of text segment memory
  78.        with other processes (kilobyte-seconds).  */
  79.     long ru_ixrss;
  80.     /* Amount of data segment memory used (kilobyte-seconds).  */
  81.     long ru_idrss;
  82.     /* Amount of stack memory used (kilobyte-seconds).  */
  83.     long ru_isrss;
  84.     /* Number of soft page faults (i.e. those serviced by reclaiming
  85.        a page from the list of pages awaiting reallocation.  */
  86.     long ru_minflt;
  87.     /* Number of hard page faults (i.e. those that required I/O).  */
  88.     long ru_majflt;
  89.     /* Number of times a process was swapped out of physical memory.  */
  90.     long ru_nswap;
  91.     /* Number of input operations via the file system.  Note: This
  92.        and `ru_oublock' do not include operations with the cache.  */
  93.     long ru_inblock;
  94.     /* Number of output operations via the file system.  */
  95.     long ru_oublock;
  96.     /* Number of IPC messages sent.  */
  97.     long ru_msgsnd;
  98.     /* Number of IPC messages received.  */
  99.     long ru_msgrcv;
  100.     /* Number of signals delivered.  */
  101.     long ru_nsignals;
  102.     /* Number of voluntary context switches, i.e. because the process
  103.        gave up the process before it had to (usually to wait for some
  104.        resource to be available).  */
  105.     long ru_nvcsw;
  106.     /* Number of involuntary context switches, i.e. a higher priority process
  107.        became runnable or the current process used up its time slice.  */
  108.     long ru_nivcsw;
  109.   };
  110.  
  111. /* Return resource usage information on process indicated by WHO
  112.    and put it in *USAGE.  Returns 0 for success, -1 for failure.  */
  113. int __getrusage __P ((enum __rusage_who __who, struct rusage * __usage));
  114. int getrusage __P ((enum __rusage_who __who, struct rusage * __usage));
  115.  
  116. /* Function depends on CMD:
  117.    1 = Return the limit on the size of a file, in units of 512 bytes.
  118.    2 = Set the limit on the size of a file to NEWLIMIT.  Only the
  119.        super-user can increase the limit.
  120.    3 = Return the maximum possible address of the data segment.
  121.    4 = Return the maximum number of files that the calling process can open.
  122.    Returns -1 on errors.  */
  123. long int __ulimit __P ((int __cmd, long int __newlimit));
  124. long int ulimit __P ((int __cmd, long int __newlimit));
  125.  
  126.  
  127. /* Priority limits.  */
  128. #define    PRIO_MIN    -20    /* Minimum priority a process can have.  */
  129. #define    PRIO_MAX    20    /* Maximum priority a process can have.  */
  130.  
  131. /* The type of the WHICH argument to `getpriority' and `setpriority',
  132.    indicating what flavor of entity the WHO argument specifies.  */
  133. enum __priority_which
  134.   {
  135.     PRIO_PROCESS = 0,        /* WHO is a process ID.  */
  136.     PRIO_PGRP = 1,        /* WHO is a process group ID.  */
  137.     PRIO_USER = 2,        /* WHO is a user ID.  */
  138.   };
  139.  
  140. /* Return the highest priority of any process specified by WHICH and WHO
  141.    (see above); if WHO is zero, the current process, process group, or user
  142.    (as specified by WHO) is used.  A lower priority number means higher
  143.    priority.  Priorities range from PRIO_MIN to PRIO_MAX (above).  */
  144. extern int getpriority __P ((enum __priority_which __which, int __who));
  145.  
  146. /* Set the priority of all processes specified by WHICH and WHO (see above)
  147.    to PRIO.  Returns 0 on success, -1 on errors.  */
  148. extern int setpriority __P ((enum __priority_which __which, int __who,
  149.                  int __prio));
  150.  
  151.  
  152. __END_DECLS
  153.  
  154. #endif /* resource.h  */
  155.